# -*- coding:utf-8 -*—

# -*- coding:utf-8 -*—
#!/usr/bin/python
# -*- coding:utf-8 -*-
# @Time    :2021/12/19 17:41
# @Author   : 亮哥
# @Mail    : yxl20160@126.com
# @File      : excel_transfrom_json.py
# Software  : PyCharm
import os
import time

import pandas as pd
import json



def save_json(open_path):
    # json_list = json_inputs(open_path)
    df = pd.read_excel(open_path)
    filename = os.path.basename(open_path)
    # print(os.path.basename(path))

    stem, suffix = os.path.splitext(filename)
    # print(stem)  # test
    # print(suffix)  # .py
    exportPath = os.path.split(os.path.abspath(open_path))[0]
    now_time = time.strftime('%Y-%m-%d-%H-%M-%S', time.localtime())
    outname = "./"+stem+"excel转txt" + now_time + ".txt"
    # print(outname)
    outputPath = exportPath +outname
    # outputPath = exportPath +'./excel转txt1.txt'
    df.to_csv(outputPath, sep='\t', index=None)



if __name__ == '__main__':
    # open_path = r'C:\Users\tslilove\Desktop\haha.xlsx'
    # open_path = r'F:\json\json转excel.xlsx'
    # open_path = r"F:\data\水电流域\2022.09.26预报数据对比\9月预报数据对比\9月份实测\实时9月份.xlsx"
    # open_path = r"F:\data\水电流域\2022.09.26预报数据对比\9月预报数据对比\9月份实测\导出数据2\实时9月份数据2.xlsx"
    # open_path = r"F:\data\水电流域\2022.09.26预报数据对比\9月预报数据对比\9月份实测\导出数据2\实时数据9月3.xlsx"
    # open_path = r"F:\data\水电流域\2022.09.26预报数据对比\2022.10.09十月预测数据\九月全月数据(1).xlsx"
    # open_path = r"F:\data\水电流域\2022.10.11全国行政区划修改\json转txt2022-10-21-15-56-16-副本.xlsx"
    # open_path = r"F:\data\水电流域\2022.09.26预报数据对比\距平降雨出图\出图\result_excelDisMeasureResult.xlsx"
    #open_path = r"F:\data\水电流域\2022.09.26预报数据对比\2022.10.23距平降雨出图\2022.10.23八月份实测数据\8月实时数据（玖天）(1).xlsx"
    # open_path = r"F:\data\水电流域\2022.09.26预报数据对比\2022.10.23距平降雨出图\hwhTest20221023juping\9月多年平均降雨(1).xlsx"
    open_path = r"F:\data\水电流域\2022.09.26预报数据对比\2022.10.23距平降雨出图\2.9月实况数据\9月降雨实况-玖天网格数据.xlsx"

    # save_path = 'transfrom.json'
    save_json(open_path)
    print("----完成----")
